import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    View,
    Image,
    Dimensions,
    ListView,
    TouchableOpacity,
    Platform
} from 'react-native';
import {Toast,ModalIndicator,Badge} from 'teaset';
const {height, width} = Dimensions.get('window');
export default class NewsChatItem extends Component {
    constructor(props) {
        super(props);
        this.state = {}
    };

    render() {
        const {item,ID}=this.props;
        return (
            <View style={styles.container}>
                {item.index==0
                    ?(<View style={{height:1,width:width,backgroundColor:'#e2e2e3'}}/>)
                    :(null)}
                <TouchableOpacity
                    onPress={()=>{Actions.ChatInterfacePage({ID:ID,toID:item.item.toClientId,
                        id:item.item.clientId,topic:item.item.topic,head:this.props.head,nickname:item.item.nickname,
                        callback:()=>{
                            if(this.props.callback){
                                this.props.callback('refresh')
                            }
                        }}
                    )}}
                    style={styles.labelView}>
                    <Image
                        source={{uri:ImageHead.baseApi+item.item.head}}
                        style={{marginLeft:15,height:49,width:49,borderRadius:49/2}}/>
                    <View style={[{marginLeft:15,marginRight:15,width:width-93,height:67,justifyContent:'center'},{
                        marginTop:Platform.OS==='ios'?0:0
                    }]}>
                        <View style={{flexDirection:'row',justifyContent:'space-between'}}>
                            <Text style={{fontSize:15,color:'#000'}}>{item.item.nickname}</Text>
                            <Text style={{color:'#777676',fontSize:12}}>{item.item.timeFomat}</Text>
                        </View>
                        <View style={{flexDirection:'row',justifyContent:'space-between',marginTop:10}}>
                            <Text
                                style={{width:width-120,color:'#777676',fontSize:12}}
                                numberOfLines={1}>{item.item.message}</Text>
                            {item.item.count ==0||item.item.count==undefined
                                ?(null)
                                :(<Badge count={item.item.count}/>)}
                        </View>
                    </View>
                </TouchableOpacity>
                {item.index==this.props.chatData.length-1
                    ?(<View style={{height:0.5,width:width,backgroundColor:'#e2e2e3'}}/>)
                    :(null)}
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#f0f0f0'
    },
    labelView:{
        width:width,
        height:67,
        backgroundColor:'#ffffff',
        flexDirection:'row',
        alignItems:'center',
    },
    noticeLabelView:{
        flexDirection:'row',
        justifyContent:'space-between',
        marginLeft:14,
        marginRight:14
    },
    iconView:{
        flexDirection:'row',
        alignItems:'center',
    },
    iconMsg:{
        fontSize:14,
        color:'#000'
    }
});
